import { Controller, Get, Param, UseGuards, Request, Body, Put, Post, UsePipes } from '@nestjs/common';
import { userChapterService } from './chapter.service';
import { AuthGuard } from '../../guards/auth.guard';
import { User, userType } from "../user.decorators";
import { UserChapterDto, UserChapterSchema } from './dto/user-chapter.dto';
import { ZodValidationPipe } from '../../pipes/zod-validation.pipe';

@Controller('user-chapter')
export class userChapterController {
  constructor(private readonly userChapterService: userChapterService) {}
  @Put()
  @UseGuards(AuthGuard)
  getCourseList(
    @User() user: userType,
    @Body(new ZodValidationPipe(UserChapterSchema)) body: UserChapterDto
  ) {
    return this.userChapterService.submitUserCourseChapter(user.userId, body);
  }

  @Get('/update-time/:id')
  @UseGuards(AuthGuard)
  updateStudyTime(
    @User() user: userType,
    @Param('id') id: string,
  ) {
    return this.userChapterService.updateStudyTime(user.userId, id);
  }
}

